Skip to content

Check the 10-bit video roundtrip gain explicitly instead of loosening the bound - #92

Open
hhoppe wants to merge 1 commit into
google:mainfrom
hhoppe:video-10bit-test
Open

hhoppe wants to merge 1 commit into
google:mainfrom
hhoppe:video-10bit-test

Conversation

@hhoppe

@hhoppe hhoppe commented Sep 25, 2026

Copy link
Copy Markdown
Contributor

test_video_read_write_10bit currently tolerates FFmpeg 8 by raising factor from 0.8 to 2.5, which leaves the residual error effectively unchecked.

The mechanism: FFmpeg <= 7.1 converts 16-bit <> 10-bit by a plain shift of 6 in both directions, so the round trip is exact. FFmpeg 8.0 still encodes with the shift but decodes by 65535/1020, taking the legacy peak 255 << 2 as white, so the round trip gains 65535/65280 = 257/256.

This version measures that gain by projection, asserts it is within 1% of unity, divides it out, and then checks the residual at the original factor = 0.8. It passes with FFmpeg 8.0.1; on FFmpeg <= 7.1 the gain is 1, so the test reduces to the original one.

🤖 Generated with Claude Code

… the bound

FFmpeg <= 7.1 converts 16-bit <> 10-bit by a plain shift of 6 in both
directions, so the round trip is exact.  FFmpeg 8.0 still encodes with the
shift but decodes by 65535/1020, taking the legacy peak 255 << 2 as white, so
the round trip gains 65535/65280 = 257/256.

Rather than raising factor from 0.8 to 2.5, measure the gain by projection,
assert that it is within 1% of unity, divide it out, and check the residual at
the original factor = 0.8.
@hhoppe hhoppe mentioned this pull request Sep 25, 2026
@hhoppe

hhoppe commented Sep 25, 2026

Copy link
Copy Markdown
Contributor Author

Unit tests pass on the fork's CI for head commit 32b00db (Python 3.10 and 3.x): https://github.com/hhoppe/mediapy/actions/runs/36083142253

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant